<template>
	<a-row>
		<h3  class='fontWeight  '> 订单详情</h3>
		<span >创建时间：{{form.createTime | formatDate}}   &nbsp;&nbsp;  创建人 ：{{form.createUserName}}</span>
		  <a-tabs  class='mt28' defaultActiveKey="1"
		      tabPosition="left"
		      :style="{ height: '100%'}"   @change='(val)=>tabChange(val)'
		    >
		      <a-tab-pane tab="订单货物详情" key="1">
		      		<h3  class='fontWeight'>交易方</h3>
		      		<a-row  class='ft16'> 
		      			<a-col :span='12' :offset='2'  v-for='(item,index) in trade_relation_data'  :key='index'>

		      				<span  v-if='item.transactionType==1'><span>供应商公司：</span>{{item.entList[0].name}}</span>
		      				<span  v-if='item.transactionType==2'>贸易商：{{item.entList[0].name}}</span>
		      				<span  v-if='item.transactionType==3'>贸易商：{{item.entList[0].name}} <br />买家公司：{{item.entList[1].name}}</span>
		      			 </a-col> 
		      		</a-row>
		      		<h3  class='fontWeight  mt12'>交易基本信息</h3>
		      		<a-row> 
						<a-col  :xs='{span:24}'  :md='{span:12}'>
							<a-form-item 
									:label-col="formItemLayout.labelCol"
									:wrapper-col="formItemLayout.wrapperCol"
							>
								<span slot="label"  style="position: relative;">
							        出口商 <sup  class='labelsup'>(shipper/exporter)</sup>
							      </span>
							      {{form.exporter}} 
							</a-form-item>
							<a-form-item 
									:label-col="formItemLayout.labelCol"
									:wrapper-col="formItemLayout.wrapperCol"
							>
								<span slot="label"  style="position: relative;">
							        出口国 <sup   class='labelsup'>(country of export)</sup>
							      </span>
							      {{form.countryOfExport}} 
							</a-form-item>
							<a-form-item 
									:label-col="formItemLayout.labelCol"
									:wrapper-col="formItemLayout.wrapperCol"
							>
								<span slot="label"  style="position: relative;">
							        货物原产地 <sup  class='labelsup'>(country of origin goods)</sup>
							      </span>
							      {{form.origin}} 
							</a-form-item>
							<a-form-item 
									:label-col="formItemLayout.labelCol"
									:wrapper-col="formItemLayout.wrapperCol"
							>
								<span slot="label"  style="position: relative;">
							        最终抵运目的国 <sup  class='labelsup'>(country of ultimate destination)</sup>
							      </span>
							      {{form.destination}} 
							</a-form-item>
							<a-form-item 
									:label-col="formItemLayout.labelCol"
									:wrapper-col="formItemLayout.wrapperCol"
							>
								<span slot="label"  style="position: relative;">
							        贸易条款 <sup  class='labelsup'>(trade terms)</sup>
							      </span>
							      {{form.tradeTerms | tradeTerms}} 
							</a-form-item>
						</a-col>
						<a-col  :xs='{span:24}'  :md='{span:12}'>
							<a-form-item 
									:label-col="formItemLayout.labelCol"
									:wrapper-col="formItemLayout.wrapperCol"
							>
								<span slot="label"  style="position: relative;">
							        收件方 <sup class='labelsup'>(consignee)</sup>
							      </span>
							      {{form.consignee}} 
							</a-form-item>
							<a-form-item 
									:label-col="formItemLayout.labelCol"
									:wrapper-col="formItemLayout.wrapperCol"
							>
								<span slot="label"  style="position: relative;">
							        进口商 <sup  class='labelsup'>(importer if other than consignee)</sup>
							      </span>
							      {{form.importer}} 
							</a-form-item>
							
						</a-col> 
		      		</a-row>
		      		<h3  class='fontWeight  mt12'>交易货物信息</h3>
		      		<router-link  :to="{path:'/order/cargoadd#1',query:{code:currentOrderCode}}"  ><a-button class='mt12'  type='primary'>点击查看货单</a-button></router-link>
		      </a-tab-pane>
		      <a-tab-pane tab="合同信息" key="2">
		      		<a-table :columns="columns_contact" :dataSource="trade_relation_data"  :pagination='false' >
		      			<!-- 上游公司 -->
					    <span slot="buyer" slot-scope="text,record"  >  
					    	<span  v-for='(item,index) in record.entList'  :key='index'>
					    		<span  v-if='item.code == text'>{{item.name}}</span>
					    	</span>  
					    </span> 
					    <!-- 下游公司 -->
					    <span slot="seller" slot-scope="text,record"  >  
					    	<span  v-for='(item,index) in record.entList'  :key='index'>
					    		<span  v-if='item.code == text'>{{item.name}}</span>
					    	</span>  
					    </span> 
					    <!-- 合同关系 -->
					    <span slot="transactionType" slot-scope="text,record"  >  
					    	{{text | transactionType}}  
					    </span>
					    <!-- 合同金额 -->
					    <span slot="contractAmt" slot-scope="text,record"  >  
					    	{{text}}{{record.contractAmtUnit | moneyUnit}}
					    </span>
					    <span  slot='contractFile'  slot-scope="text,record" > 
					    	<a-button  type='primary'  @click='getFileInfo(record)'>查看/上传</a-button>
					    	<a-button  type='primary'  @click='produceContract(record)' >制作合同</a-button>
					    </span>
					  </a-table>
		      </a-tab-pane>
		      <a-tab-pane tab="提单信息" key="3">
		      		<!-- 未录入 通用 -->
			      	<a-row  v-if='!billdata'>
			      		当前未录入提单 <br>
			      		<a-button  type='primary'  class='mt12'  @click='entering()'>录入</a-button>
			      	</a-row> 
			      	<table  border  width='100%'  style='text-align: center;'  class='table_lading  mb28'  v-if='billdata'>
			      		<tr>
			      			<td  colspan="4"  class='text-left  fontWeight  ft16'>提单信息</td>
			      		</tr>
			      		<tr>
			      			<th>提单号</th>
			      			<th>提单类型</th>
			      			<th>是否电放</th>
			      			<th>提单附件</th>
			      		</tr>
			      		<tr>
			      			<td>{{billdata.billNum}}</td>
			      			<td>
			      				<span  v-if='billdata.billType ==1'>正本</span>
						    	<span  v-else>复印件</span>
						    </td>
			      			<td>
			      				<span  v-if='billdata.telexReleaseFlag ==1'>是</span>
						    	<span  v-else>否</span>
						    </td>
			      			<td>
			      				<ul>
						    		<li  v-for = '(item,index)  in  billdata.fileList '  :key='index'>
						    			<span  class="link"  @click='downloadFile(item.code)' ><a-icon type="paper-clip" />{{item.name}}</span>
						    		</li>
						    	</ul> 
			      			</td>
			      		</tr>
			      		<tr>
			      			<td  colspan="4"  class='text-right'>
			      				录入人：{{billdata.createUserName}} <br />录入时间：{{billdata.createTime | formatDate}}
			      				<a-icon type="edit"  class='absolute cursor' :style='{fontSize :"16px",top:"20px",right:"20px"}'  title='编辑'  @click='editEntering()'/>
			      			</td>
			      		</tr>
			      		<tr> 
			      			<td  colspan="4"  class='text-left'>
			      				<span  class='fontWeight  ft16'>提单状态</span><br/> 
			      				当前发送方：{{currentBillForm.senderName}}（<span  class='color-success'>已寄出</span>）——————当前接收方：{{currentBillForm.receiverName}}（<span  v-if='currentBillForm.billStatus==1'  class='color-red'>未确认</span><span  v-if='currentBillForm.billStatus==2'  class='color-success'>已收到</span>）
			      			</td> 
			      		</tr>
			      		<tr>
			      			<td   colspan="4"  class='text-left'>
			      				<a-steps  :current="currentStep"> 
								    <a-step  v-for='(item,index) in entNorepeat'  :key='item.code' :title='item.name' >
								    	<span slot="description"> 
								    		<span  v-if='item.code == currentBillForm.receiver '>  
									    		<span  v-if='currentBillForm.billStatus == 1'>未确认 <br> </span>
									    		<span  v-if='currentBillForm.billStatus == 2'>
									    			已收到<span  v-if='currentBillForm.receiver!=currentBuyer'>，待寄出</span> <br> 
									    		</span>
									    		<a-button  @click='confirmReVisible  = true ' :disabled='currentBillForm.billStatus==2'>收到</a-button>
									    		<a-button  @click='confirmSend(item,index)'  v-if='currentBillForm.receiver!=currentBuyer'  :disabled='currentBillForm.billStatus==1 '>寄出</a-button>
									    	</span> 
								    	</span>
								    </a-step> 
								  </a-steps>
			      			</td>
			      		</tr>
			      	</table> 
					<a-card title="历史操作信息："  class='mb28  mt28'   v-if='ladingLogData && ladingLogData.length>0'>
						<a-card-grid style="width:100%; ">  
							<a-timeline  >
					    		<a-timeline-item  v-for='(item,index)  in  ladingLogData'  :key='index'>
							    		 操作时间：{{item.createTime | formatDate}}<br />
							    		 操作内容：{{item.logContent}}<br />
							    		 操作部门： <br />
							    		 操作者：{{item.createUserName}} <br /> 
							    </a-timeline-item> 
							  </a-timeline>  
						</a-card-grid>
					</a-card> 
		      </a-tab-pane>
		      <a-tab-pane tab="交易管理" key="4"  >
					<a-row  v-if='creditData.LastQuota'>
					  <span  class='color-red'>*</span>本合同买方授信余额为<span  class='color-red'>
					  {{creditData.LastQuota}}{{creditData.CreditLineUnit | moneyUnit}}</span>
					  ，单笔最高授信额度为<span  class='color-red'>{{creditData.EachMaxQuota}}{{creditData.CreditLineUnit | moneyUnit}}</span>
					</a-row>
					<a-row v-else  class='color-red'>*本合同买方授信余额未录入，请注意款项额度。</a-row>

		      		<a-table :columns="columns" :dataSource="trade_relation_data"  :pagination='false'  class='mt12'>
		      			<!-- 上游公司 -->
					    <span slot="buyer" slot-scope="text,record"  >  
					    	<span  v-for='(item,index) in record.entList'  :key='index'>
					    		<span  v-if='item.code == text'>{{item.name}}</span>
					    	</span>  
					    </span> 
					    <!-- 下游公司 -->
					    <span slot="seller" slot-scope="text,record"  >  
					    	<span  v-for='(item,index) in record.entList'  :key='index'>
					    		<span  v-if='item.code == text'>{{item.name}}</span>
					    	</span>  
					    </span> 
					    <!-- 合同关系 -->
					    <span slot="contract" slot-scope="text,record"  >  
					    	{{record.entList[0].name}} ——  {{record.entList[1].name}}
					    </span>
					    <!-- 合同金额 -->
					    <span slot="contractAmt" slot-scope="text,record"  >  
					    	{{text}}{{record.contractAmtUnit | moneyUnit}}
					    </span>
					    <!-- 已结清 -->
					    <span slot="settleAmt" slot-scope="text,record"  >  
					    	{{text}}{{record.settleAmtUnit | moneyUnit}}
					    </span>
					    <span slot="action" slot-scope="text, record"> 
					      	<span  v-if='record.transactionType == 1'>
					      		<a href="javascript:;"  @click='editform_money(record,1)'>付款</a>
					      		<a-divider type="vertical" /> 
					      		<a href="javascript:;"  @click='list_reApay(record,2)'>付款记录</a> 
					      	</span>
					      	<span  v-if='record.transactionType==2'> 
					      		<a href="javascript:;"  @click='editform_money(record,1)'>付款</a>
					      		<a-divider type="vertical" /> 
					      		<a href="javascript:;"  @click='list_reApay(record,1)'>收款</a>
					      		<a-divider type="vertical" /> 
					      		<a href="javascript:;"  @click='list_reApay(record,2)'>付款记录</a>
					      	</span>
					      	<span  v-if='record.transactionType==3'> 
					      		<a href="javascript:;"  @click='editform_money(record,2)'>收款</a>
					      		<a-divider type="vertical" /> 
					      		<a href="javascript:;"  @click='list_reApay(record,1)'>收款记录</a>
					      	</span>
					      
					    </span>
					  </a-table>
		      </a-tab-pane> 
		      <a-tab-pane tab="退税信息" key="5">
		      	    <a-row  v-if='!refundForm' >
			      		<h3>退税信息未录入</h3>
			      		<a-button  @click='refundAdd()'   type='primary'  class='mt12'>录入</a-button>
		      		</a-row>
					<a-row   v-else>
						<a-form   class='relative'> 
							<a-form-item
								label="日期"
								:label-col="formItemLayout.labelCol"
								:wrapper-col="formItemLayout.wrapperCol"
								>
								{{refundForm.createTime  | formatDates}}
							</a-form-item> 
							<a-form-item
								label="退税金额"
								:label-col="formItemLayout.labelCol"
								:wrapper-col="formItemLayout.wrapperCol"
								>
								 {{refundForm.taxRefundAmt}} {{refundForm.taxRefundAmtUnit | moneyUnit}}
							</a-form-item> 
							<a-form-item
								label="退税税率"
								:label-col="formItemLayout.labelCol"
								:wrapper-col="formItemLayout.wrapperCol"
								>
								{{refundForm.taxRefundRate}}
							</a-form-item>
							<a-form-item
								label="退税状态"
								:label-col="formItemLayout.labelCol"
								:wrapper-col="formItemLayout.wrapperCol"
								>
								{{refundForm.taxRefundStatus | taxRefundStatus}}
							</a-form-item>
							<a-form-item
								label="退税凭证"
								:label-col="formItemLayout.labelCol"
								:wrapper-col="formItemLayout.wrapperCol"
								> 
								<ul  v-if='refundForm.fileList && refundForm.fileList.length>0'>
									<li  v-for = '(item,index)  in  refundForm.fileList '  :key='index'>
						    			<span  class="link"  @click='downloadFile(item.code)' ><a-icon type="paper-clip" />{{item.name}}</span>
						    		</li>
								</ul>

								<span  v-else>暂无</span>
							</a-form-item>  
							 <a-form-item
								label="录入人"
								:label-col="formItemLayout.labelCol"
								:wrapper-col="formItemLayout.wrapperCol"
								>
								{{refundForm.createUserName}}
							</a-form-item> 
							<a-form-item
								label="录入时间"
								:label-col="formItemLayout.labelCol"
								:wrapper-col="formItemLayout.wrapperCol"
								>
								{{refundForm.createTime | formatDate}}
							</a-form-item> 
							<a-icon type="edit"  class='absolute cursor' :style='{fontSize :"16px",top:"20px",right:"20px",left:"20px",color:"#1890ff"}'  title='编辑'  @click='refundEdit(refundForm)'/>
						</a-form>
						<a-card title="历史操作信息："  class='mb28' >
							<a-card-grid style="width:100%; ">  
								<a-timeline   v-if='refundLogData && refundLogData.length>0'>
						    		<a-timeline-item  v-for='(item,index)  in  refundLogData'  :key='index'>
								    		 操作时间：{{item.createTime | formatDate}}<br />
								    		 操作内容：{{item.logContent}}<br />
								    		 操作部门： <br />
								    		 操作者：{{item.createUserName}} <br /> 
								    </a-timeline-item> 
								  </a-timeline>
								  <span  v-else>
								  	暂无
								  </span>
								
							</a-card-grid>
						</a-card> 
					</a-row>
		      </a-tab-pane>
		      
		   </a-tabs>
		<!-- 上传合同附件查看 -->
		<contractFile  ref='contractFileModal'  :visible='contractVisible'  v-on:handleOk='contractVisible=false'  v-on:handleCancel='contractVisible=false'></contractFile>
		 
	    <a-modal title="确认收到提单" ref='confirmReModal'  v-model="confirmReVisible" @ok="handleOk(2)"     okText="确定" cancelText="取消">
			<p>确认已收到提单？确认后，将更新提单状态</p>
	    </a-modal>
	    <a-modal title="寄出提单" ref='confirmSeModal'  v-model="confirmSeVisible" @ok="handleOk(1)"     okText="确定" cancelText="取消">
			<p>请选择收方：<a-select   style="width: 120px" v-model='current_lading_Receive'>
					      <a-select-option  v-for='(item,index)  in  receivable_ent'  :key='item.code' :value='item.code'>{{item.name}}</a-select-option> 
					    </a-select>
			</p>
	    </a-modal>
		<!-- 提单 -->
		<lading  ref='billLading'  :visible='billVisible'  v-on:handleOk='updateLading'  v-on:handleCancel='billVisible=false'></lading>
		<!-- 付/收 款modal -->
		<payMent  ref='payModalForm'  :visible='payModalShow'  v-on:handleOk='payModalShow=false'  v-on:handleCancel='payModalShow=false'></payMent>
		 
		<!-- 收付记录modal -->
		<payList  ref='payModalList'  :visible='payListShow'  v-on:handleOk='payListShow=false'  v-on:handleCancel='payListShow=false'></payList>
		<!-- 退税记录 -->
		<refundForm  ref='refundForm'  :visible='refundModal'   v-on:handleOk='finishedRefund()'  v-on:handleCancel='refundModal=false'></refundForm>
	</a-row>

</template>
<script>
import  {  detailOrder,submitLadingStatus,submitRefund,LadingDetailByOrder,LadingLogList,LadingStatusList,RefundDetailByOrder,RefundLogList,getEntCredit  }  from  '@/api/order/index'

import  lading  from  '@/components/order/lading'
import  fileUpload  from  '@/components/common/fileUpload'
import  payMent  from  '@/components/order/payMent' 
import  payList  from  '@/components/order/payList'
import  contractFile  from  '@/components/order/contractFile'
import  refundForm  from  '@/components/order/refundForm'

const columns = [
	{
	  title: '上游公司',
      dataIndex: 'buyer',
      key: 'buyer',
      slots: { title: 'customTitle' },
      scopedSlots: { customRender: 'buyer' },
    },
    {
    	title:'下游公司',
    	dataIndex:'seller',
    	scopedSlots: { customRender: 'seller' },
    },
    {
    	title:'合同关系',
    	dataIndex:'contract',
    	scopedSlots: { customRender: 'contract' },
    },
    {
    	title:'合同金额',
    	dataIndex:'contractAmt',
    	scopedSlots: { customRender: 'contractAmt' },
    },
    {
    	title:'已结清',
    	dataIndex:'settleAmt',
    	scopedSlots: { customRender: 'settleAmt' },
    },
    {
    	title:'结算',
    	scopedSlots: { customRender: 'action' },
    },
    // {
    // 	title:'合同附件',
    // 	dataIndex:'ddd'
    // },
]
const columns_contact = [
	{
	  title: '上游公司',
      dataIndex: 'buyer',
      key: 'buyer',
      slots: { title: 'customTitle' },
      scopedSlots: { customRender: 'buyer' },
    },
    {
    	title:'下游公司',
    	dataIndex:'seller',
    	scopedSlots: { customRender: 'seller' },
    },
    {
    	title:'合同关系',
    	dataIndex:'transactionType',
    	scopedSlots: { customRender: 'transactionType' },
    },
    {
    	title:'合同金额',
    	dataIndex:'contractAmt',
    	scopedSlots: { customRender: 'contractAmt' },
    }, 
    {
    	title:'合同附件',
    	dataIndex:'contractFile',
    	scopedSlots: { customRender: 'contractFile' },
    },
]
	export default{
		name:'orderDetail',
		data(){
			return {
				columns,// table_交易管理
				columns_contact,// table_合同管理
				receivable_ent:[],//option_receiveEnt
				entNorepeat:[],// option_allEnt 
				formItemLayout:{
					labelCol:{
						md:{span:7} 
					},
					wrapperCol:{
						sm:{span:12}
					}
				},  
				billVisible:false,//modal_提单
				confirmReVisible:false,/*modal_提单确认框*/
				confirmSeVisible:false, 
				contractVisible:false,//modal_查看合同 
				payModalShow:false,//modal_付款
				payListShow:false,//modal_收付 
				refundModal:false,//modal_退税
				
 				/*当前订单*/
				currentOrderCode:'',
				currentPrjCode:'',
				currentBuyer:'',//buyercode_当前订单的买方 提单状态到最后一列时不显示寄出 && 提单状态当前高亮   
				form:{},/*form_baseinfo*/ 
				billdata:{},/*form_billform*/
				trade_relation_data:[],/*dataList_trasction*/ 
				currentBillForm:{},/*form_lastbill_Status*/   
				ladingLogData:[],/*dataList_lading_optionLog*/  
				current_lading_Receive:'',/*v-model_option_ladingSelected*/
				currentStep:null,//currentStep_ladingStep 
				refundForm:{},//form_refund
				refundLogData:[],//dataList_refundLog

				creditData:{},//授信额度
 
			}
		},
		 beforeCreate () {
	         this.form = this.$form.createForm(this); 
	       },
		created(){
			this.currentOrderCode = this.$route.query.code 
			this.pageInit(this.currentOrderCode )
		},

		methods:{
			pageInit(code){
				detailOrder(code).then((res)=>{ 
					if(res.data.flag == true){
						let data  = res.data.data 
						this.form = data
						/*买家code*/
						this.form.transactionVOList.forEach((item)=>{ 
								if(item.transactionType == 3 ){
									this.currentBuyer = item.seller 
								}  
						})
						/*prjcode*/ 
						this.currentPrjCode = data.prjCode
						/*form_billform*/
						this.billdata = data.ladingBillVO
						/*dataList_trasction*/
						this.trade_relation_data = data.transactionVOList
						/*form_refund*/
						this.refundForm = data.bizTaxRefundVO
						// option_allEnt
						this.transfer(this.trade_relation_data)
					} 
				})
			},

			/******************提单******************/
			/* 根据订单code获取提单详情 */
			ladingDetailByOrder(){
				LadingDetailByOrder(this.currentOrderCode).then((res)=>{
					if(res.data.flag == true){ 
						/*form_billform*/
						this.billdata = res.data.data
						/*dataList_billstate*/
						let billstatusData = this.billdata.ladingBillStatusVOList 
						/*currentBillForm*/ 
						if(billstatusData.length>0){ 
							this.currentBillForm = billstatusData[billstatusData.length-1] 
							this.entNorepeat.forEach((item,index)=>{ 
								if(item.code == this.currentBillForm.receiver){ 
									/*改变当前步骤显示*/
									this.currentStep = index
								}
							})
						}
						/*initial_lading_statusAdd*/
						else{
							let form={}
					 		form.ladingBillCode = this.billdata.code
					 		form.billStatus = 2
					 		form.receiver =  this.entNorepeat[1].code
					 		form.sender = this.entNorepeat[0].code 
					 		submitLadingStatus(form).then((res)=>{
					 			if(res.data.flag == true){ 
					 				this.ladingDetailByOrder() 
					 				this.getLadingLog()
					 			}
					 		})
						} 
					}
				})
			},
			/* 获取提单记录日志 + 状态日志 */
			getLadingLog(){
				let LadingLog = new Promise((resolve,reject)=>{
					LadingLogList({code:this.billdata.code,pageSize:1000}).then((res)=>{
						if(res.data.flag == true){
							resolve(res.data.dataList)
						}
						else{
							reject()
						}
					})
				})
				let LadingStatus = new Promise((resolve,reject)=>{
					LadingStatusList({code:this.billdata.code,pageSize:1000}).then((res)=>{
						if(res.data.flag == true){
							resolve(res.data.dataList)
						}
						else{
							reject()
						}
					})
				})

				Promise.all([LadingLog,LadingStatus]).then((result)=>{
					let arr = result[0].concat(result[1])
					//将数组按时间排序
					this.sortBytime(arr)
					arr.forEach((item,index)=>{
						//收寄记录
						if(!item.receiverName){
							item.logContent = item.logType == 1 ? '新增录入提单':'修改提单信息'
						}
					})
					this.ladingLogData = arr 
				}).catch((error)=>{

				})
			},

			/******************退税******************/
			/* 根据订单code获取退税详情 */
			getRefundByOrder(){
				RefundDetailByOrder(this.currentOrderCode).then((res)=>{
					if(res.data.flag == true){
						this.refundForm = res.data.data
						this.getRefundLog()
					}
				})
			},
			/* 退税日志记录 */
			getRefundLog(){
				RefundLogList({code:this.refundForm.code,pageSize:1000}).then((res)=>{
					if(res.data.flag==true){
						let arr = res.data.dataList
						arr.forEach((item,index)=>{
							//收寄记录
							if(!item.receiverName){
								item.logContent = item.logType == 1 ? '新增退税信息':'修改退税信息'
							}
						})
						this.refundLogData = arr
					}
				})
			}, 
			
			/***********modal操作***********/
			//合同
			/*查看已上传文件 */
			getFileInfo(data){ 
				this.$refs.contractFileModal.$emit('openDialog',data)
				this.contractVisible  = true 
			},
			//生成合同跳转
			produceContract(data){ 
				//exit_editStatus
				this.$router.push({path:'/order/contractAdd',query:{code:data.orderCode,transactionCode:data.code,isEdit:data.contractVO==null ? false:true}}) 
			}, 

			// 提单
			/*提单 modal show*/
			entering(){ 
				this.$refs.billLading.$emit('openDialog',this.currentOrderCode,this.currentPrjCode)
				this.billVisible = true
			},
			/*提单编辑  waiting*/
			editEntering(){
				this.$refs.billLading.$emit('editDialog',this.currentOrderCode)
				this.billVisible = true
			},
			//提单关闭，更新状态
		 	updateLading(){
		 		this.billVisible = false
		 		this.ladingDetailByOrder()
		 		this.getLadingLog()
		 	},
		 	/*
				    收到方    确认收到
				    		 收         寄    （传递数据）
				receiver=> (receiver ,sender)

					寄出方    确认寄出
							 收         寄    （传递数据）
				receiver=> (nextreceive,receive)
		 	*/
		 	/* 修改 提单状态
		 	   billStatus	    string   提单状态(0:未寄出 1:已寄出 2:已收到)
		 	   ladingBillCode	string   提单code
		 	   receiver	        string   接收人
 			   sender	        string   发送人
		 	*/  
		 	handleOk(num){
		 		let form={}
		 		form.ladingBillCode = this.billdata.code
		 		form.billStatus = num
		 		form.receiver = num==2 ? this.currentBillForm.receiver : this.current_lading_Receive
		 		form.sender = num==2? this.currentBillForm.sender : this.currentBillForm.receiver
		 		submitLadingStatus(form).then((res)=>{
		 			if(res.data.flag == true){
		 				this.$message.success(res.data.msg)
		 				this.ladingDetailByOrder()
		 				this.getLadingLog()
		 				if(num==2){
		 					this.confirmReVisible = false
		 				}
		 				if(num==1){
		 					this.confirmSeVisible = false
		 				} 
		 			}
		 		})
		 	}, 
		 	//确认寄出 modal
		 	confirmSend(data,index){ 
		 		//寄出方option——list
		 		this.entNorepeat.forEach((item,index)=>{
		 			if(item.code == this.currentBillForm.receiver){  
		 				this.receivable_ent = this.entNorepeat.slice(index+1)//收方option
		 			}
		 		})  
		 		this.confirmSeVisible  = true 
		 	}, 

		 	/*pay modal show*/
		 	editform_money(data,num){   
		 		//付款 & 收款  根据交易关系判断 贸易商付款/贸易商收款
	 			this.$refs.payModalForm.$emit('openDialog',data,this.currentBuyer)
	 			this.payModalShow  = true
		 		 
		 	},
		 	/*paylist modal show   2-付款*/
		 	list_reApay(data,index){ 
		 		this.$refs.payModalList.$emit('openDialog',data,index,this.currentBuyer)
		 		this.payListShow = true
		 	},
		 	

			//退税
			refundAdd(){
				this.$refs.refundForm.$emit('openDialog',this.currentOrderCode,this.currentPrjCode)
		 		this.refundModal = true
			},
			refundEdit(data){
				this.$refs.refundForm.$emit('editDialog',data)
		 		this.refundModal = true
			},
			/*退税完成*/
			finishedRefund(){
				this.refundModal = false
				this.getRefundByOrder()
			},
		 	
		    /***************工具函数***************/
			tabChange(val){ 
				if(val == 3 && this.billdata){ 
					this.ladingDetailByOrder()
					this.getLadingLog()
				}
				if(val == 4){
					
					//请求本合同买方授信额度
			        getEntCredit(this.currentBuyer).then((res)=>{
			          // console.log(res)
			            if(res == false){
			                this.$info({
			                    title: '提示',
			                    content: '本合同买方授信额度尚未录入，请注意款项额度',
			                    okText:'知道了'
			                  }); 
			                return false
			            }
			            else if(res.data.flag == true){
			              this.creditData = res.data.data 
			            } 
			        })
				}
				if(val == 5 && this.refundForm){
					this.getRefundByOrder()
				}
			},
			//数组排序
			sortBytime(arr){ 
			    for(let j=0;j<arr.length-1;j++){
			    //两两比较，如果前一个比后一个大，则交换位置。
			       for(let i=0;i<arr.length-1-j;i++){
			            if(arr[i].createTime<arr[i+1].createTime){
			                [arr[i+1],arr[i]] = [arr[i],arr[i+1]]
			            }
			        } 
			    }
			},
			// 交易关系 转换 所有相关公司
			transfer(data){
				let entArr = []
				data.forEach((item)=>{
					entArr.push(item.entList)
				}) 

				entArr.forEach((item,index)=>{ 
					if(index == 0){
						this.entNorepeat.push(item[0])
					}
					this.entNorepeat.push(item[1])
				}) 
			},

		},
		components:{
			lading,
			fileUpload,
			payMent, 
			payList,
			contractFile,
			refundForm
		},
		computed: { 
			 
		},
	}
</script>

<style scoped="='scoped">
.ant-card-grid:hover{box-shadow: 0 0 0 rgba(0, 0, 0, 0)}	

.table_lading th,td{padding: 20px;}
.labelsup{right:-6px;position: absolute;top:22px}
</style>